package com.platform.acl.service.impl;

import com.platform.acl.entity.User;
import com.platform.acl.entity.UserRole;
import com.platform.acl.entity.VO.ConditionUserVo;
import com.platform.acl.entity.excel.UserInfo;
import com.platform.acl.mapper.UserRoleMapper;
import com.platform.acl.service.RoleService;
import com.platform.acl.service.UserRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.platform.acl.service.UserService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author CZF
 * @since 2022-02-28
 */
@Service("userService")
public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> implements UserRoleService {

    @Autowired
    UserService userService;

    @Autowired
    RoleService roleService;

    @Override
    @Transactional
    public void saveUserMessage(UserInfo userInfo) {
        User user = new User();
        UserRole userRole = new UserRole();
        BeanUtils.copyProperties(userInfo,user);

        userService.addUserMess(user);
        userRole.setRoleId(userInfo.getRoleId());
        userRole.setUserId(user.getId());

        baseMapper.insert(userRole);
    }

    @Override
    public List<UserInfo> UserInfoByPage(int i, ConditionUserVo conditionUserVo) {
        return null;
    }
}
